/**
 * LOADING MULTIPLE OBJECTS, CAMERA AND LIGHT OPTIONS.
 */
package  
{
	import flare.basic.*;
	import flare.loaders.collada.*;
	import flare.system.*;
	import flare.utils.*;
	import flash.display.*;
	import flash.events.*;
	import flash.geom.*;
	
	[SWF(frameRate = 120, backgroundColor = 0x808080, width = 800, height = 600 )]
	/**
	 * ...
	 * @author Ariel Nehamd
	 */
	public class Test05 extends Sprite
	{
		private var scene:Scene3D;
		
		public function Test05() 
		{
			ColladaLoader.texturesFolder = "textures";
			
			scene = new Scene3D( this );
			scene.addEventListener( Scene3D.UPDATE_EVENT, updateEvent );
			
			scene.addChildFromFile( "elsa.dae" );
			scene.addChildFromFile( "test1.dae" );
			
			// camera posiion and orientation.
			scene.camera.far = 10000;
			scene.camera.setPosition( 0, 150, -150 );
			scene.camera.lookAt( 0, 2, 0 );
			
			// light parameters.
			scene.ambientColor = new Vector3D( 0.2, 0.2, 0.2 );  // <-- RGB ambient light color.
			scene.defaultLight.color = new Vector3D( 1, 1, 1, 1 ); // <-- RGB light colors and contrast.
			scene.defaultLight.setRotation( 40, 40, 0 );
			
		}
		private function updateEvent(e:Event):void 
		{
			// simple orbit camera.
			if ( Input3D.mouseDown )
			{
				scene.camera.rotateY( Input3D.mouseXSpeed, false, Vector3DUtils.ZERO );
				scene.camera.rotateX( Input3D.mouseYSpeed, true, Vector3DUtils.ZERO );
			}
			
			scene.camera.translateZ( scene.camera.getPosition().length * Input3D.delta / 20 );
			
			scene.defaultLight.rotateY( 2 );
		}
		
	}

}